import datetime

from django.shortcuts import render

# Create users views here.
context = {
    'name': 'zhang san',
    'age': 30,
    'likes': ['movie', 'game', 'code'],
    'address': {'city': '深圳', 'province': '广东'},
    'stars': [
        ['马化腾', '马云', '马斯克'],
        ['雷军', '李彦宏', '张一鸣'],
        ['扎克伯格', '比尔盖茨', '任正非']
    ],
    'dt': datetime.datetime.now(),
    'code': '<b>I am a good man</b>',
    'nosafe_code': """
    <script>
        var n = 3;
        while(n--){
            alert('哈哈');
        };
    </script>
    """
}

def home(request):
    """ 模版语法 """

    return render(request, 'index.html')


def variable(request):
    """ 模版语法：变量 """
    global context

    return render(request, 'users/variable.html', context=context)


def if_statement(request):
    """ 模版语法：if语句 """
    global context

    return render(request, 'users/if-statement.html', context=context)


def for_statement(request):
    """ 模版语法：for语句 """
    global context

    return render(request, 'users/for-statement.html', context=context)


def filter(request):
    global context

    return render(request, 'users/filter.html', context=context)


def father(request):
    """ 模版继承 """

    return render(request, 'users/father.html')

def child(request):

    return render(request, 'users/child.html')
